#include <math.h>
#include "CChar.h"
#include "CItem.h"

#include "CShopValuePacket.h"

CShopValuePacket::CShopValuePacket(unsigned char invSlotID, unsigned long sellPrice, unsigned char fameLevel) {
	fameMult = 0.00;

	calcFameMultiplier(fameLevel);

	this->type = 0x3D;
	this->size = 0x08;

	memset(data, 0, sizeof(data));

	unsigned long price = 0;
	price = (int)ceil(sellPrice * fameMult);

	memcpy(data+0x04-0x04, &price, 4);
	data[0x08-0x04] = invSlotID;

}

CShopValuePacket::~CShopValuePacket() {
}

void CShopValuePacket::calcFameMultiplier(unsigned char fameLevel) {
	// fame level 1 = 1.00
	// fame level 9 = 1.025
	fameMult = 1 + (0.025 * (fameLevel - 1) / 8);
}
